﻿using System;
using System.Linq;

namespace easyccms.BusinessLayer
{
    /// <summary>
    /// Unit of work methods.
    /// </summary>
    public interface IUnitOfWork : IDisposable
    {
        /// <summary>
        /// Loads the specified id.
        /// </summary>
        /// <typeparam name="T">Load entity type of T.</typeparam>
        /// <param name="id">The id.</param>
        /// <returns>Returns loaded entity T.</returns>
        T Load<T>(int id);

        /// <summary>
        /// Gets the list.
        /// </summary>
        /// <typeparam name="T">Representation of entity type T.</typeparam>
        /// <returns>Get list of entities of defined type.</returns>
        IQueryable<T> GetList<T>();

        /// <summary>
        /// Saves the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Save(object entity);

        /// <summary>
        /// Deletes the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Delete(object entity);

        /// <summary>
        /// Starts the transaction.
        /// </summary>
        void StartTransaction();

        /// <summary>
        /// Commits the transaction.
        /// </summary>
        void CommitTransaction();

        /// <summary>
        /// Rollbacks the transaction.
        /// </summary>
        void RollbackTransaction();

    }
}